﻿using System;
using System.Collections.Generic;
using System.Text;

namespace Parseq.Core
{
    public class Location
    {
        private long bytes = 0;

        public Location() { }

        public Location(long bytes)
        {
            this.bytes = bytes;
        }

        public Location IncBytes(long offset)
        {
            return new Location(this.bytes + offset); 
        }

        public long Bytes
        {
            get { return this.bytes; } 
        }

        public override string ToString()
        {
            return string.Format("<Location:{0}>", this.bytes); 
        }

        public override bool Equals(object obj)
        {
            if (obj is long) {
                return this.bytes == (long)obj;
            } else if (obj is Location) {
                return this.bytes == ((Location)obj).Bytes; 
            } else {
                return false; 
            }
        }

        public override int GetHashCode()
        {
            return this.bytes.GetHashCode();
        }
    }
}
